package com.ruoyi.erp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.erp.domain.GlCashtable;
import com.ruoyi.erp.service.IGlCashtableService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 凭证现金流量Controller
 * 
 * @author ztj
 * @date 2023-04-28
 */
@RestController
@RequestMapping("/erp/cashtable")
public class GlCashtableController extends BaseController
{
    @Autowired
    private IGlCashtableService glCashtableService;

    /**
     * 查询凭证现金流量列表
     */
    @PreAuthorize("@ss.hasPermi('erp:cashtable:list')")
    @GetMapping("/list")
    public TableDataInfo list(GlCashtable glCashtable)
    {
        startPage();
        List<GlCashtable> list = glCashtableService.selectGlCashtableList(glCashtable);
        return getDataTable(list);
    }

    /**
     * 导出凭证现金流量列表
     */
    @PreAuthorize("@ss.hasPermi('erp:cashtable:export')")
    @Log(title = "凭证现金流量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GlCashtable glCashtable)
    {
        List<GlCashtable> list = glCashtableService.selectGlCashtableList(glCashtable);
        ExcelUtil<GlCashtable> util = new ExcelUtil<GlCashtable>(GlCashtable.class);
        util.exportExcel(response, list, "凭证现金流量数据");
    }

    /**
     * 获取凭证现金流量详细信息
     */
    @PreAuthorize("@ss.hasPermi('erp:cashtable:query')")
    @GetMapping(value = "/{iYear}")
    public AjaxResult getInfo(@PathVariable("iYear") String iYear)
    {
        return success(glCashtableService.selectGlCashtableByIYear(iYear));
    }

    /**
     * 新增凭证现金流量
     */
    @PreAuthorize("@ss.hasPermi('erp:cashtable:add')")
    @Log(title = "凭证现金流量", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GlCashtable glCashtable)
    {
        return toAjax(glCashtableService.insertGlCashtable(glCashtable));
    }

    /**
     * 修改凭证现金流量
     */
    @PreAuthorize("@ss.hasPermi('erp:cashtable:edit')")
    @Log(title = "凭证现金流量", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GlCashtable glCashtable)
    {
        return toAjax(glCashtableService.updateGlCashtable(glCashtable));
    }

    /**
     * 删除凭证现金流量
     */
    @PreAuthorize("@ss.hasPermi('erp:cashtable:remove')")
    @Log(title = "凭证现金流量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{iYears}")
    public AjaxResult remove(@PathVariable String[] iYears)
    {
        return toAjax(glCashtableService.deleteGlCashtableByIYears(iYears));
    }
}
